package com.neusoft.neuiotms.dcam.fixed.model;

import java.util.List;

import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.OneToOne;
import javax.persistence.OrderColumn;
import javax.persistence.Table;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.annotations.Proxy;

import com.neusoft.bizcore.web.jpa.model.AbstractAuditModel;
import com.neusoft.bizcore.web.jpa.model.Comment;
import com.neusoft.neuiotms.common.model.SerialNumber;
import com.neusoft.neuiotms.dcam.fixed.model.enums.AssetCodeConnector;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 资产编码规则
 *
 * @author 黄鑫临
 */
@Getter
@Setter
@ToString
@Entity
@Table(name = "neuiot_fixed_asset_code_rule")
@org.hibernate.annotations.Table(appliesTo = "neuiot_fixed_asset_code_rule", comment = "资产编码规则表")
@Proxy(lazy = false)
public class AssetCodeRule extends AbstractAuditModel {

    /**
     *
     */
    private static final long serialVersionUID = 1L;

    /** 已选规则项 */
    @ElementCollection
    @CollectionTable(name = "neuiot_fixed_asset_code_rule_field")
    @OrderColumn(name = "priority")
    @Column(length = 1024)
    @Comment("varchar(1024) COMMENT '已选规则项'")
    @LazyCollection(LazyCollectionOption.FALSE)
    private List<String> fileds;

    /** 流水号长度 */
    @Comment("int(11) NULL COMMENT '流水号长度'")
    private Integer padLength = 4;

    /** 连接符 */
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) COMMENT '连接符'")
    private AssetCodeConnector connector = AssetCodeConnector.EMPTY;

    @OneToOne
    private SerialNumber serialNumber;
}
